<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>


<style type="text/css">
	*{
		text-align: center;
	}
	span{
		color:red;
	}
	
	.cpage a {
	width: 50px;
	height: 50px;
	display: inline-block;
	border-radius: 50%;
	background-color: orange;
	line-height: 50px;
	text-align: center;
	text-decoration: none;
	font-size: 12px;
	font-weight: bold;
	color: white;
}

</style>
</head>
<body>
<h1>商品分页列表</h1>

<hr/>

	<table border="0" width="100%" cellpadding="8px">
			
			<c:forEach items="${requestScope.list }" var="p">
				<tr align="center">

					<td valign="top">
							<img src="${applicationScope.pic_url }${p.imgurls}"/>
					</td>

				
					<td width="30%"><c:out value="${p.name }"></c:out><br/>
					<c:out value="${p.price }"></c:out><br/>
					<c:out value="${p.type }"></c:out><br/>
					</td>
					
					<td>
					<c:if test="${p.pnum > 0 }">
						<font color="blue">有货</font>
					</c:if>
					<c:if test="${p.pnum <= 0 }">
						<font color="red">无货</font>
					</c:if>
					</td>

					<td>
                        <c:if test="${p.state == 1}">
							<a href="javaScript:void(0);" onclick="jiaProd('${p.id}',0)">下架商品</a>
                            <a href="${pageContext.request.contextPath}/seller/prodInfoSeller?id=${p.id}">修改商品</a>
                        </c:if>
                        <c:if test="${p.state == 0}">
							<a href="${pageContext.request.contextPath}/seller/jiaProd?id=${p.id}&state=1">上架商品</a>
                        </c:if>
					</td>
				</tr>
				
				<tr> <td colspan="4"><hr/></td></tr>
				
			</c:forEach>
		</table>

</body>

<script>

	function jiaProd(id,state) {
		var flag = confirm("您确定要下架该商品吗？");
		if(flag){
			location.href = "${pageContext.request.contextPath}/seller/jiaProd?id="+id+"&state="+state;
		}

	}
</script>


</html>